import { BrowserRouter, Route, Routes } from 'react-router-dom'
import CharacterPage from './CharacterPage/CharacterPage'
import CommonLoginPage from './Login/Pages/CommonLoginPage'
import ProgramListPage from './ProgramList/Pages/ProgramlistPage'
import ProgramManagePage from './ProgramManage/Pages/ProgramManagePage'
import {
  AccountBookOutlined,
  AuditOutlined,
  BulbOutlined,
  DeliveredProcedureOutlined,
  DeploymentUnitOutlined,
  FlagOutlined,
  ForkOutlined,
  HomeOutlined,
  InsuranceOutlined,
} from '@ant-design/icons'

const App = () => {
  return (
    <BrowserRouter>
      <div className="App">
        <Routes>
          <Route
            path="/"
            element={
              <CommonLoginPage
                backgroundImageUrl="https://huafeiiot.cdn.toskies.com/@resources/images/hotel_1000x1000.jpg"
                logo="华飞智能酒店PMS"
                footer={
                  <div>
                    <a href="http://www.huafeiiot.com">
                      华飞智能酒店PMS - 使用说明
                    </a>
                  </div>
                }
                scanLogin={{
                  code: "http://www.huafeiiot.com",
                  tip: (
                    <div>使用微信扫码登录</div>
                  )
                }}
                accountLogin={{
                  onLogin: async (account: string, password: string) => {
                    let url = `http://192.168.50.222:3000/auth/login`
                    let flag = await fetch(url, {
                      method: 'post',
                      body: JSON.stringify({
                        username: account,
                        password: password,
                      }),
                      headers: {
                        'Content-Type': 'application/json',
                      },
                    })
                      .then((response) => {
                        return response.json()
                      })
                      .then((json) => {
                        const data = json.data
                        if (data.access_token) return true
                        else return false
                      })
                    console.log(flag)

                    return flag
                  },
                }}
                phoneNumberLogin={{
                  codeFetchWaitTime: 60,
                  onGetCode: (phoneNumber: string) => {
                    alert(`已获取短信验证码!phoneNumber: ${phoneNumber}`)
                  },
                  onLogin: (phoneNumber: string, code: string) => {
                    alert(`登录成功!phoneNumber: ${phoneNumber}, code: ${code}`)
                  },
                }}
              />
            }
          />
          <Route
            path="/character"
            element={
              <CharacterPage
                usersData={[
                  {
                    id: '001',
                    name: '超级管理员',
                    desc: '超级管理员desc超级管理员desc超级管理员desc超级管理员desc超级管理员desc超级管理员desc超级管理员desc超级管理员desc',
                    setAccount: 1,
                    avatar: 'https://joeschmoe.io/api/v1/random',
                  },
                  {
                    id: '002',
                    name: '财务',
                    desc: '财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc',
                    setAccount: 10,
                    avatar: 'https://joeschmoe.io/api/v1/random',
                  },
                  {
                    id: '003',
                    name: '收银员',
                    desc: '收银员desc收银员desc收银员desc收银员desc收银员desc收银员desc收银员desc收银员desc收银员desc收银员desc收银员desc',
                    setAccount: 10,
                    avatar: 'https://joeschmoe.io/api/v1/random',
                  },
                  {
                    id: '004',
                    name: '导购',
                    desc: '导购desc导购desc导购desc导购desc导购desc导购desc导购desc导购desc导购desc导购desc导购desc导购desc导购desc',
                    setAccount: 10,
                    avatar: 'https://joeschmoe.io/api/v1/random',
                  },
                  {
                    id: '005',
                    name: '财务',
                    desc: '财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc财务desc',
                    setAccount: 10,
                    avatar: 'https://joeschmoe.io/api/v1/random',
                  },
                ]}
              />
            }
          />
          <Route
            path="/programList"
            element={
              <ProgramListPage
                programData={[
                  {
                    id: '001',
                    name: '工商户管理系统',
                    member: {
                      leaderName: '张长章',
                      memberNum: 10,
                      workHour: 123,
                    },
                    progress: {
                      time: '2019.12.1',
                      success: 60,
                      milepost: [
                        { id: '1', stage: '启动阶段', percent: 30 },
                        { id: '2', stage: '需求调研', percent: 40 },
                        { id: '3', stage: '程序设计与开发', percent: 50 },
                        { id: '4', stage: '软件测试', percent: 70 },
                        { id: '5', stage: '实施运维', percent: 100 },
                      ],
                    },
                    contract: {
                      contract: '合同金额',
                      contractCash: '200万',
                      income: '收入金额',
                      incomeCash: '170万',
                      invoice: '发票金额',
                      invoiceCash: '70万',
                      collection: '回款金额',
                      collectionCash: '90万',
                    },
                  },
                  {
                    id: '002',
                    name: '工程项目统计系统',
                    member: {
                      leaderName: '张长章',
                      memberNum: 10,
                      workHour: 123,
                    },
                    progress: {
                      time: '2019.12.1',
                      success: 60,
                      milepost: [
                        { id: '1', stage: '启动阶段', percent: 30 },
                        { id: '2', stage: '需求调研', percent: 40 },
                        { id: '3', stage: '程序设计与开发', percent: 50 },
                        { id: '4', stage: '软件测试', percent: 70 },
                        { id: '5', stage: '实施运维', percent: 100 },
                      ],
                    },
                    contract: {
                      contract: '合同金额',
                      contractCash: '200万',
                      income: '收入金额',
                      incomeCash: '170万',
                      invoice: '发票金额',
                      invoiceCash: '70万',
                      collection: '回款金额',
                      collectionCash: '90万',
                    },
                  },
                  {
                    id: '003',
                    name: '工程云移动项目',
                    member: {
                      leaderName: '张长章',
                      memberNum: 10,
                      workHour: 123,
                    },
                    progress: {
                      time: '2019.12.1',
                      success: 100,
                      milepost: [
                        { id: '1', stage: '启动阶段', percent: 30 },
                        { id: '2', stage: '需求调研', percent: 40 },
                        { id: '3', stage: '程序设计与开发', percent: 50 },
                        { id: '4', stage: '软件测试', percent: 70 },
                        { id: '5', stage: '实施运维', percent: 100 },
                      ],
                    },
                    contract: {
                      contract: '合同金额',
                      contractCash: '200万',
                      income: '收入金额',
                      incomeCash: '170万',
                      invoice: '发票金额',
                      invoiceCash: '70万',
                      collection: '回款金额',
                      collectionCash: '90万',
                    },
                  },
                  {
                    id: '004',
                    name: '移动外勤综合看板项目',
                    member: {
                      leaderName: '张长章',
                      memberNum: 10,
                      workHour: 123,
                    },
                    progress: {
                      time: '2019.12.1',
                      success: 60,
                      milepost: [
                        { id: '1', stage: '启动阶段', percent: 30 },
                        { id: '2', stage: '需求调研', percent: 40 },
                        { id: '3', stage: '程序设计与开发', percent: 50 },
                        { id: '4', stage: '软件测试', percent: 70 },
                        { id: '5', stage: '实施运维', percent: 100 },
                      ],
                    },
                    contract: {
                      contract: '合同金额',
                      contractCash: '200万',
                      income: '收入金额',
                      incomeCash: '170万',
                      invoice: '发票金额',
                      invoiceCash: '70万',
                      collection: '回款金额',
                      collectionCash: '90万',
                    },
                  },
                  {
                    id: '005',
                    name: '杭州燃气集团数据可视化项目',
                    member: {
                      leaderName: '张长章',
                      memberNum: 10,
                      workHour: 123,
                    },
                    progress: {
                      time: '2019.12.1',
                      success: 0,
                      milepost: [
                        { id: '1', stage: '启动阶段', percent: 30 },
                        { id: '2', stage: '需求调研', percent: 40 },
                        { id: '3', stage: '程序设计与开发', percent: 50 },
                        { id: '4', stage: '软件测试', percent: 70 },
                        { id: '5', stage: '实施运维', percent: 100 },
                      ],
                    },
                    contract: {
                      contract: '合同金额',
                      contractCash: '200万',
                      income: '收入金额',
                      incomeCash: '170万',
                      invoice: '发票金额',
                      invoiceCash: '70万',
                      collection: '回款金额',
                      collectionCash: '90万',
                    },
                  },
                ]}
              />
            }
          />
          <Route
            path="programManage"
            element={
              <ProgramManagePage
                listData={[
                  {
                    key: '1',
                    nextkey: ['2', '3'],
                    icon: <AuditOutlined />,
                    selectIcon: <AuditOutlined style={{ color: 'white' }} />,
                    title: '步骤1',
                    state: 0,
                    content: [
                      {
                        key: '001',
                        name: '第一个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '1.4',
                        action: false,
                      },
                    ],
                  },
                  {
                    key: '2',
                    nextkey: ['3'],
                    icon: <AccountBookOutlined />,
                    selectIcon: (
                      <AccountBookOutlined style={{ color: 'white' }} />
                    ),
                    title: '步骤2',
                    state: 0,
                    content: [
                      {
                        key: '002',
                        name: '第一个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '600',
                        time: '200',
                        action: false,
                      },
                      {
                        key: '003',
                        name: '第二个任务',
                        type: '财务',
                        isBegin: false,
                        specifiedTime: '6',
                        time: '0.1',
                        action: false,
                      },
                    ],
                  },
                  {
                    key: '3',
                    nextkey: ['4', '6'],
                    icon: <BulbOutlined />,
                    selectIcon: <BulbOutlined style={{ color: 'white' }} />,
                    title: '步骤3',
                    state: 1,
                    content: [
                      {
                        key: '004',
                        name: '第一个任务',
                        type: '财务',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '4.8',
                        action: false,
                      },
                      {
                        key: '005',
                        name: '第二个任务',
                        type: '工程',
                        isBegin: false,
                        specifiedTime: '6',
                        time: '5.2',
                        action: false,
                      },
                      {
                        key: '006',
                        name: '第三个任务',
                        type: '设计',
                        isBegin: false,
                        specifiedTime: '6',
                        time: '66',
                        action: true,
                      },
                    ],
                  },
                  {
                    key: '4',
                    nextkey: ['5'],
                    icon: <DeliveredProcedureOutlined />,
                    selectIcon: (
                      <DeliveredProcedureOutlined style={{ color: 'white' }} />
                    ),
                    title: '步骤4',
                    state: 2,
                    content: [
                      {
                        key: '007',
                        name: '第1个任务',
                        type: '设计',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '0',
                        action: false,
                      },
                      {
                        key: '008',
                        name: '第2个任务',
                        type: '工程',
                        isBegin: false,
                        specifiedTime: '6.5',
                        time: '5',
                        action: false,
                      },
                      {
                        key: '009',
                        name: '第三个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '12',
                        action: true,
                      },
                      {
                        key: '010',
                        name: '第4个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '14',
                        action: false,
                      },
                    ],
                  },
                  {
                    key: '5',
                    nextkey: ['6'],
                    icon: <DeploymentUnitOutlined />,
                    selectIcon: (
                      <DeploymentUnitOutlined style={{ color: 'white' }} />
                    ),
                    title: '步骤5',
                    state: 2,
                    content: [
                      {
                        key: '011',
                        name: '第1个任务',
                        type: '设计',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '0',
                        action: false,
                      },
                      {
                        key: '012',
                        name: '第2个任务',
                        type: '工程',
                        isBegin: false,
                        specifiedTime: '6.5',
                        time: '5',
                        action: false,
                      },
                      {
                        key: '013',
                        name: '第三个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '12',
                        action: true,
                      },
                      {
                        key: '014',
                        name: '第4个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '14',
                        action: false,
                      },
                    ],
                  },
                  {
                    key: '6',
                    nextkey: ['7'],
                    icon: <ForkOutlined />,
                    selectIcon: <ForkOutlined style={{ color: 'white' }} />,
                    title: '步骤6',
                    state: 2,
                    content: [
                      {
                        key: '015',
                        name: '第1个任务',
                        type: '设计',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '0',
                        action: false,
                      },
                      {
                        key: '016',
                        name: '第2个任务',
                        type: '工程',
                        isBegin: false,
                        specifiedTime: '6.5',
                        time: '5',
                        action: false,
                      },
                      {
                        key: '017',
                        name: '第三个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '11.5',
                        action: true,
                      },
                      {
                        key: '018',
                        name: '第4个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '13.2',
                        action: false,
                      },
                    ],
                  },
                  {
                    key: '7',
                    nextkey: ['8'],
                    icon: <FlagOutlined />,
                    selectIcon: <FlagOutlined style={{ color: 'white' }} />,
                    title: '步骤7',
                    state: 2,
                    content: [
                      {
                        key: '019',
                        name: '第1个任务',
                        type: '设计',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '0',
                        action: false,
                      },
                      {
                        key: '020',
                        name: '第2个任务',
                        type: '工程',
                        isBegin: false,
                        specifiedTime: '6.5',
                        time: '5',
                        action: false,
                      },
                      {
                        key: '021',
                        name: '第三个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '12',
                        action: true,
                      },
                      {
                        key: '022',
                        name: '第4个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '14',
                        action: false,
                      },
                    ],
                  },
                  {
                    key: '8',
                    nextkey: ['9'],
                    icon: <HomeOutlined />,
                    selectIcon: <HomeOutlined style={{ color: 'white' }} />,
                    title: '步骤8',
                    state: 2,
                    content: [
                      {
                        key: '023',
                        name: '第1个任务',
                        type: '设计',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '0',
                        action: false,
                      },
                      {
                        key: '024',
                        name: '第2个任务',
                        type: '工程',
                        isBegin: false,
                        specifiedTime: '6.5',
                        time: '5',
                        action: false,
                      },
                      {
                        key: '025',
                        name: '第三个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '12',
                        action: true,
                      },
                      {
                        key: '026',
                        name: '第4个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '14',
                        action: false,
                      },
                    ],
                  },
                  {
                    key: '9',
                    nextkey: [],
                    icon: <InsuranceOutlined />,
                    selectIcon: (
                      <InsuranceOutlined style={{ color: 'white' }} />
                    ),
                    title: '步骤9',
                    state: 2,
                    content: [
                      {
                        key: '027',
                        name: '第1个任务',
                        type: '设计',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '0',
                        action: false,
                      },
                      {
                        key: '028',
                        name: '第2个任务',
                        type: '工程',
                        isBegin: false,
                        specifiedTime: '6.5',
                        time: '5',
                        action: false,
                      },
                      {
                        key: '029',
                        name: '第三个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '12',
                        action: true,
                      },
                      {
                        key: '030',
                        name: '第4个任务',
                        type: '工程',
                        isBegin: true,
                        specifiedTime: '6',
                        time: '14',
                        action: false,
                      },
                    ],
                  },
                ]}
              />
            }
          />
        </Routes>
      </div>
    </BrowserRouter>
  )
}

export default App
